package com.example.video_module;

import com.example.common.databus.LiveDataBus;
import com.example.common.mvvm.BaseEntity;
import com.example.common.mvvm.viewmodel.BaseViewModel;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class VideoViewModel extends BaseViewModel<VideoRepository> {
    public LiveDataBus<List<VideoEntity.DataBean.VideoData>> videoList = new LiveDataBus<>();
    @Override
    public void onResult(BaseEntity entity) {
        if (entity instanceof VideoEntity){
            VideoEntity list= (VideoEntity) entity;
            List<VideoEntity.DataBean.VideoData> data = list.data.data;
            videoList.postValue(data);
            System.out.println("========"+data.size());
        }
    }

    @Override
    protected void initData() {
        repository.requestData()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }
}
